import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TestModule } from './test/test.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AuthModule } from './auth/auth.module';
import { UserModule } from './user/user.module';
import { LogModule } from './log/log.module';
import { AttendanceModule } from './attendance/attendance.module';
import { DeptModule } from './dept/dept.module';
import { ProjectModule } from './project/project.module';
import { RoleModule } from './role/role.module';
import { SystemModule } from './system/system.module';
import { BasicModule } from './basic/basic.module';
import { WorkModule } from './work/work.module';
import { CalendarModule } from './calendar/calendar.module';
import { ApplyModule } from './apply/apply.module';
import { AnnouncementModule } from './announcement/announcement.module';
import { DingtalkModule } from './dingtalk/dingtalk.module';
import { NoticeModule } from './notice/notice.module';
import { DeductionModule } from './deduction/deduction.module';
import { ScheduleModule } from '@nestjs/schedule';
import { RecordModule } from './record/record.module';
import { SeasModule } from './seas/seas.module';
import { DormitoryModule } from './dormitory/dormitory.module';
import { PropertyModule } from './property/property.module';
import { PaymentModule } from './payment/payment.module';
import { PostModule } from './post/post.module';
import { DepartModule } from './depart/depart.module';
import { ChannelModule } from './channel/channel.module';
import { ContractModule } from './contract/contract.module';
import { PurchaseModule } from './purchase/purchase.module';
import { SalaryModule } from './salary/salary.module';
import { V2ApplyModule } from './v2/apply/v2.apply.module';

@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forRootAsync({
      useFactory: () => {
        console.log(process.env.orm_username)
        console.log(process.env.orm_password)
        console.log(process.env.orm_database)
        return ({
          type: "mysql",
          host: process.env.orm_host,
          port: Number(process.env.orm_port),
          username: process.env.orm_username,
          password: process.env.orm_password,
          database: process.env.orm_database,
          // synchronize: process.env.orm_synchronize === "true",
          // dropSchema: process.env.orm_dropSchema === "true",
          logging: process.env.orm_logging === "true",
          charset: "utf8",
          entities: ["./**/*.entity.js"],
          connectorPackage: "mysql2"
        })
      }
    }),
    ScheduleModule.forRoot(),
    LogModule,
    UserModule,
    AuthModule,
    DingtalkModule,
    WorkModule,
    AttendanceModule,
    ApplyModule,
    DeptModule,
    ProjectModule,
    RoleModule,
    TestModule,
    SystemModule,
    BasicModule,
    CalendarModule,
    AnnouncementModule,
    NoticeModule,
    DeductionModule,
    RecordModule,
    SeasModule,
    DormitoryModule,
    PropertyModule,
    PaymentModule,
    PostModule,
    DepartModule,
    ChannelModule,
    ContractModule,
    PurchaseModule,
    SalaryModule,
    V2ApplyModule
  ],
  controllers: [],
  providers: [],
})
export class AppModule { }
